/*************************************************************************
	> File Name: P2362.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-07-23 10:38:52
 ************************************************************************/
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

void solve(int n) {
    vector<int> arr(n + 1), dp(n + 1, 1), f(n + 1, 1);
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j < i; j++) {
            if (arr[i] >= arr[j]) {
                if (dp[i] == dp[j] + 1) {
                    f[i] += f[j];
                } else if (dp[i] < dp[j] + 1) {
                    dp[i] = dp[j] + 1;
                    f[i] = f[j];
                }
            }
        }
    }
    int ans = 0, cnt = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dp[i]);
    }
    for (int i = 1; i <= n; i++) {
        if (dp[i] == ans) {
            cnt += f[i];
        }
    }
    cout << ans << " " << cnt << endl;
    return ;
}

int main() {
    int n;
    cin >> n;
    while (n--) {
        int m;
        cin >> m;
        solve(m);
    }
    return 0;
}
